<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bin-Blog &#187; Search Results  &#187;  &#8220;Hello Script&#8221;</title>
	<atom:link href="http://www.bin-co.com/blog/?s=Hello%20Script&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>My Windows/DOS Applications</title>
		<link>http://www.bin-co.com/blog/2009/01/windows-dos-applications/</link>
		<comments>http://www.bin-co.com/blog/2009/01/windows-dos-applications/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 18:11:13 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[dos]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=224</guid>
		<description><![CDATA[I got into programming before I got into Linux - consequently, many of my earlier programs were targeted for the windows platform. I want to showcase those apps in this post. I no longer use them - but <strong>if anyone finds any of these useful, it wont go to waste</strong>.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2009/01/dos_logo.jpeg" alt="DOS Logo" title="DOS Logo" width="76" height="79" class="alignnone size-full wp-image-225 intro" align="right" /></p>
<p class="intro">I got into programming before I got into Linux &#8211; consequently, many of my earlier programs were targeted for the windows platform. I want to showcase those apps in this post. I no longer use them &#8211; but <strong>if anyone finds any of these useful, it wont go to waste</strong>.</p>
<p>I wrote many programs in my Window days. But most of them are useful only to me &#8211; its pointless to list them here. These are the list of programs that others might find interesting.</p>
<p>This post is a part of a series I am doing on Windows. The other posts in this series so far are&#8230;</p>
<ul>
<li><a href="http://www.bin-co.com/blog/2009/01/3-windows-speed-tips-from-linux-user/">3 Windows Speed Tips from a Linux User</a></li>
<li><a href="http://www.bin-co.com/blog/2009/01/windows-hacks-the-escape/">Windows Hacks: ‘The Escape’</a></li>
<li><a href="http://www.bin-co.com/blog/2009/01/using-linux-for-a-better-windows-experience/">Using Linux for a better Windows Experience</a></li>
</ul>
<h2>Command Line Apps</h2>
<p>I had an affection for the Command Line even when I was in windows. Due to the lack of tools in DOS, I created a few DOS tools myself. Most of them are done in C++&#8230;</p>
<h3><a href="http://binnyva.com/pro/dos/bd/">bd &#8211; &#8216;dir&#8217; command replacement</a></h3>
<p>BD is a `dir` replacement. This program displays the contents of a specified folder in a colorful and more understandable way. BD displays files of different types in different colours, letting you see at a glance which files are executable, which are documents, directories etc.</p>
<blockquote><p>BD helps to cross the boundary between the starkness of DOS and the color of Windows and is a perfect utility for anyone who is experienced with Windows but wishes to start working in DOS.<br />
 &nbsp; &nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp; <strong><a href="http://www.completelyfreesoftware.com/">Completely Free Softwares</a></strong></p></blockquote>
<h3><a href="http://binnyva.com/pro/dos/boot_booster/">Boot Booster</a></h3>
<p>Boot Booster is a program that tries to put the booting time of the computer to good use. It can log the booting time, display a joke or an inspirational message that will change at every booting, display any message, display any reminders you have set etc. Boot Booster can be configured to log the booting time, shutdown time and the time the session lasted etc. <strong>Works only in Windows 95/98</strong>. It will NOT work on anything newer.</p>
<p>I don&#8217;t expect anyone will find this useful. But at the time I created it, it was one of my favorite applications. I have created other apps to parse the result of its log and create <a href="http://binnyva.blogspot.com/2006/01/my-computer-in-2005.html">some &#8216;interesting&#8217; graphics</a>.</p>
<h2>Batch Programming Helpers</h2>
<p>People into DOS will also be into batch programming. I wrote quite a few batch scripts to automate stuff. Since the batch scripting language had very little features, I wrote utilities to improve its abilities&#8230;</p>
<h3><a href="http://binnyva.com/pro/dos/batch_tk/">Batch ToolKit</a></h3>
<p>Batch ToolKit is a collection of 5 programs intended to make batch programming a bit more feature rich&#8230;</p>
<ul>
<li><a href="http://binnyva.com/pro/dos/batch_tk/#becho">Becho</a></li>
<li><a href="http://binnyva.com/pro/dos/batch_tk/#message">Message</a></li>
<li><a href="http://binnyva.com/pro/dos/batch_tk/#tnd">Tnd &#8211; Time &#8216;n Date</a></li>
<li><a href="http://binnyva.com/pro/dos/batch_tk/#select">Select</a></li>
<li><a href="http://binnyva.com/pro/dos/batch_tk/#getline">Getline</a></li>
</ul>
<p>If you are in windows and you use Batch in a non-trivial way, please switch to linux &#8211; you are going to love the features that is provided by bash(Linux shell scripting language). Then after a while, <a href="http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/">you will hate that too &#8211; and will use higher level languages</a>. And thus, a programmer is born.</p>
<h2>GUI Applications &#8211; Tcl/Tk</h2>
<p>I also did some Tcl/Tk programming in Windows to create GUI applications. I continue that even today &#8211; as Tcl/Tk is well supported in Linux(even though <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/">Tk apps looks very bad in linux</a>). All the Tcl apps I created are available on the <a href="http://www.bin-co.com/tcl/">Tcl/Tk page</a>.</p>
<p>I enjoyed programming in the Tcl language that I created a <a href="http://www.bin-co.com/tcl/tutorial/">tutorial for Tcl/Tk</a>. Later I create the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a> for <a href="http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/">Tcl(for quick reference)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2009/01/windows-dos-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello Script for C Language</title>
		<link>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/</link>
		<comments>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 17:41:49 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[scirpt]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=116</guid>
		<description><![CDATA[C &#8211; the root of all modern language&#8217;s syntax. Here is the hello script for C. A &#8216;Hello Script&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. C is a general-purpose, block structured, procedural, [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">C &#8211; the root of all modern language&#8217;s syntax. Here is the hello script for C. A &#8216;<a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a>&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language.</p>
<blockquote><p>C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie. Although C was designed for implementing system software, it is also widely used for applications. It is widely used on a great many different software platforms and computer architectures, and several popular compilers exist.</p>
<p><a href="http://en.wikipedia.org/wiki/C_(programming_language)">Wikipedia</a></p></blockquote>
<p>Unfortunately, I am not an expert in C &#8211; I prefer dynamic languages over static ones. So if you find any problems in the script, please let me know in the comments.</p>
<pre><code class="c">
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

// Function declaration
void hello(char name[]) {
 	char result[50] = "Hello, ";
 	strcat(result, name);
 	printf("%s\n", result);
}

int main() {
	int i;
	// Printing(IO)
	printf("Hello World!\n");

	// Variables, concatenation
	char name[] = "Binny";
	int year = 2008;
	printf("Hello, %s - welcome to %d\n", name, year);

	//If, else
	if (year &gt; 2008) {
		printf("Welcome to the future - yes, we have flying cars!");
	}
	else if(year &lt; 2008) {
		printf("The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!");
	}
	else {
		printf("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
	}
	printf("\n");

	// For loop
	for(i=0; i&lt;3; i++) {
		printf("%d) Hi there!\n", i);
	}

 	//Numerical Array, while
 	char rules[3][20]; //I am sure there is a better way of doing this using poiters. If you know, please leave a few 'pointers' in the comment.
 	strcpy(rules[0], "Do no harm");
 	strcpy(rules[1], "Obey");
 	strcpy(rules[2], "Continue Living");
 	i=0;
	while(i&lt;3) {
		printf("Rule %d : %s\n", i+1, rules[i]);
		i++;
	}

	// Struct - nearest thing C has to an associated array
	struct structure {
		char hello[20];
		int number;
		char foo[20];
	} associated, new_associated;
	strcpy(associated.hello, "world");
	associated.number = 1337;
	strcpy(associated.foo, "bar");
	printf("hello: %s\n", associated.hello);
	printf("number: %d\n", associated.number);
	printf("foo: %s\n", associated.foo);

	// Function calling
	hello("John Oldman");

	// Writing to a file
 	FILE *out;
 	out = fop<!-- fix wordpress bug -->en("/tmp/Hello.txt", "w");
 	char *str = "Hello From C";
 	fputs(str, out);
 	fclose(out);

	// Reading and displaying a file.
	FILE *in;
	in = fop<!-- fix wordpress bug -->en("Hello.c", "r");
	if (in) {
		while (!feof(in))
			printf("%c",fgetc(in));
	}
	fclose(in);

	// Run a system command.
	sys<!-- fix wordpress bug -->tem("ls");

	return 1;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello Script for Java</title>
		<link>http://www.bin-co.com/blog/2008/06/hello-script-for-java/</link>
		<comments>http://www.bin-co.com/blog/2008/06/hello-script-for-java/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 18:24:01 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=111</guid>
		<description><![CDATA[After the Hello Script for JavaScript, here is the Hello Script for Java. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. Warning: I am NOT an expert in Java &#8211; I am [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/06/java-logo.png" alt="" title="Java Logo" width="125" height="217" class="size-full wp-image-112 intro" align="right" /></p>
<p class="intro">After the <a href="http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/">Hello Script for JavaScript</a>, here is the Hello Script for Java. <strong class="highlight">&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<p>Warning: I am NOT an expert in Java &#8211; I am just a beginner. There <strikeout>may</strikeout> will be errors(bad programming methods &#8211; not compiler errors) in the following script. If you notice any such issues, please point them out in the comments.</p>
<h2>Code</h2>
<p>If you want to run the code, save it to a file named &#8216;Hello.java&#8217; and compile in using the command &#8216;javac Hello.java&#8217;. After that you can run the code using the command &#8216;java Hello&#8217;.</p>
<pre><code class="java">
import java.io.*;
import java.util.regex.*;

public class Hello {
	public static void main(String[] Args) {
		// Printing(IO)
		System.out.println("Hello World");

		// Variables, concatenation
		String name = "Binny";
		int year = 2008;

		System.out.println("Hello, " + name + " - welcome to " + year);

		if(year &gt; 2008) {
			System.out.println("Welcome to the future - yes, we have flying cars!");
		} else if(year &lt; 2008) {
			System.out.println("The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!");
		} else {
			System.out.println("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
		}

		// For loop
		int i=0;
		for(i=0; i&lt;3; i++) {
			System.out.println(i + ") Hi there!");
		}

		//Numerical Array, While
		String rules[] = {"Do no harm", "Obey", "Continue Living"};
		i = 0;
		while(i&lt;rules.length) {
			System.out.println("Rule " + (i+1) + " : " + rules[i]);
			i++;
		}

		// Associated array, foreach
		// Hmm - does Java have Associated arrays? ArrayList?

		String csv_string = "hello,world,how,are,you";
		String csv_values[] = csv_string.split(",");
		// No native Join method

		// Function, argument, return, call
		System.out.println(Hello.hello("Binny")); //The function definition is at the end of this file.	

		//Class stuff...
		Movie ncfom = new Movie("New Country for Old Men"); //It's a sequel!
		ncfom.printMovieDetails();

		// File IO
		// File reading, easy method...
		try {
			File read_file = new File ("/tmp/Hello.txt");
			FileReader in_stream = new FileReader(read_file); // Create a Character Input Stream
			BufferedReader in = new BufferedReader(in_stream);// Filter the Input Stream - buffers characters for efficiency
			try {
				System.out.println(in.readLine()); // read the first line
			} catch(IOException E) {
				System.out.println("No idea what went wrong. Sorry!");
			}
		} catch(FileNotFoundException E) {
			System.out.println("File not found. Sorry!");
		}

		try {
			// Writing to a file
			File out_file = new File("/tmp/HelloJava.txt");
			FileOutputStream out_stream = new FileOutputStream(out_file); // Create an Output Stream
			PrintWriter out = new PrintWriter(out_stream); // Filter bytes to ASCII
			out.println("Hello, from Java"); // Here we actually write to file
		} catch(java.io.FileNotFoundException E) {
			System.out.println("File not found. Sorry!");
		}

		System.out.println("\nLS command results...");
		// Command Executing
		try {
			// Execute a command
			String command = "ls";
			Process child = Runtime.getRuntime().exec (command);

			// Read from an input stream
			InputStream in = child.getInputStream();
			int c;
			while ((c = in.read()) != -1) {
				System.out.print((char)c);
			}
			in.close();
		} catch (IOException e) {
			System.out.println("Error");
		}

		System.out.print("\n");
		//Regular Expression
		String str = new String("Hello World");

		//Find a pattern
		Pattern hell_check = Pattern.compile("^Hell");
		Matcher matches = hell_check.matcher(str);
		if(matches.find()) System.out.println("Yup - its evil");

		//Replace
		System.out.println(str.replaceAll("l([^l])", "$1")); //Remove an 'l' from both words. Should print 'Helo Word'

	}

	//Function declaration.
	private static String hello(String name) {
		return "Hello, " + name;
	}

	// One for the OOP fanboys - Class, members, object and stuff.
	private static class Movie {
		public String name = "";
		public int rating = 0;

		public Movie(String name) {
			this.name = name;
			this.rateMovie();
		}

		public void rateMovie() {
			this.rating = (this.name.length() % 10) + 1; //IMDBs rating algorithm. True story!
		}

		public void printMovieDetails() {
			System.out.println("Movie  : " + this.name);
			System.out.println("Rating : " + this.rating);
		}
	}
}
</code></pre>
<p>Next Hello Script &#8211; C</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/06/hello-script-for-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hello Script For JavaScript</title>
		<link>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/#comments</comments>
		<pubDate>Thu, 22 May 2008 18:26:14 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=108</guid>
		<description><![CDATA[The next language to get the Hello Script treatment is JavaScript &#8211; my favorite language. Before we go any further, here is the definitions for Hello Script and JavaScript &#8211; just to make sure that we are on the same page&#8230; Hello Script &#8216;Hello Script&#8217; is a file that contains the most commonly used elements [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/05/javascript_logo.jpg" alt="Javascript Rhino Logo" title="Javascript Logo" width="230" height="194" class="alignnone size-full wp-image-109 intro" align="right" /></p>
<p class="intro">The next language to get the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a> treatment is <a href="http://www.openjs.com/">JavaScript &#8211; my favorite language</a>. Before we go any further, here is the definitions for Hello Script and JavaScript &#8211; just to make sure that we are on the same page&#8230;</p>
<dl>
<dt>Hello Script</dt>
<dd><strong class="highlight">&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</dd>
<dt><a href="http://localhost/Sites/openjs/openjs.com/about.php#about-js">JavaScript</a></dt>
<dd>JavaScript is a <strong class="highlight">client side scripting language</strong> that is used in browsers.</dd>
</dl>
<h2>Code</h2>
<p>Warning: Do not run this code &#8211; you will get a lot of alerts. If you have firebug extension, uncomment the first line &#8211; then you can run the code.</p>
<pre><code class="html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello Script for JS&lt;/title&gt;
&lt;script type="text/javascript"&gt;
//alert=console.log;
alert("Hello World");

// Variables, concatination
var name = 'Binny';
var year = 2008;
alert("Hello, " + name + " - welcome to " + year );

//If,else conditions
if (year &gt; 2008) {
	alert("Welcome to the future - yes, we have flying cars!");
}
else if(year &lt; 2008) {
	alert("The past - please don't change anything. Don't step on any butterflies. And for the sake of all thats good and holy, stay away from your parents!");
}
else {
	alert("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
}

// For loop
for(var i=0; i&lt;3; i++) {
	alert(i + ") Hi there!");
}

//Numerical Array, While
var rules = [
	'Do no harm',
	'Obey',
	'Continue Living'
];
var i = 0;
while(i&lt;rules.length) {
	alert("Rule " + (i+1) + " : " + rules[i]);
	i++;
}

// Associated array, foreach
var associated = {
	'hello'	:	'world',
	'foo'	:	'bar',
	'lorem'	:	'ipsum'
}
for(key in associated) {
	alert(key + " : " + associated[key]);
}

// Using Join and Split
csv_values = "hello,world,how,are,you".split(",");
alert(csv_values.join(":"));

// Function, argument, return, call
function hello(name) {
	return "Hello " + name;
}
hello_string = hello("Binny");
alert(hello_string);

// One for the OOP fanboys - Class, members, object and stuff.
function Movie(name) { //Constuctor
	this.name = name;
}
Movie.prototype.rateMovie = function() {
	this.rating = (this.name.length % 10) + 1; //IMDBs rating algorithm. True story!
}

Movie.prototype.printMovieDetails = function() {
	alert("Movie : " + this.name + "\nRating : " + this.rating);
}

//Create the object
ncfom = new Movie("New Country for Old Men"); //It's a sequel!
ncfom.printMovieDetails();

// Regular Expressions
string = "Hello World";
if(string.match(/^Hell/)) alert("Yup - its evil\n");
alert(string.replace(/l([^l])/g, "$1")); //Remove an 'l' from both words. Should alert('Helo Word'

/**
 * Specialized code
 */
window.onload = function() {
	var ele = document.getElementById("div-element");
	alert(ele);
	ele.innerHTML = "Hello World";
	ele.onclick = function() {
		alert("You Clicked?");
	}

	document.getElementById("text").value = "Goodbye World";
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id="div-element"&gt;&lt;/div&gt;

&lt;input type="text" value="3" id="text" /&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Script for bash</title>
		<link>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/#comments</comments>
		<pubDate>Mon, 12 May 2008 18:02:25 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=107</guid>
		<description><![CDATA[Hello Script series for Bash. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. bash bash is the most commonly used shell in Linux. That makes the bash scripting language the most popular [...]]]></description>
			<content:encoded><![CDATA[<p class="intro"><a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script series</a> for Bash. <strong>&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<h2>bash</h2>
<p><a href="http://www.gnu.org/software/bash/">bash</a> is the most commonly used shell in Linux. That makes the bash scripting language the most popular shell scripting language. OK, maybe after batch. But then again, bash is much more powerful than batch(DOS scripting language). If want to learn bash, I will recommend this tutorial &#8211; <a href="http://tldp.org/LDP/abs/html/">Advanced Bash Scripting</a></p>
<p>Officially, <a href="http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/">I hate bash</a>. I use perl or other similar high level language to create shell script. I use bash only for the <a href="http://binnyva.blogspot.com/2007/03/using-twitter-part-1-command-line.html">simplest scripts</a>. But even I admit that bash has its uses. So, here is the hello script for bash&#8230;</p>
<h2>Hello Script</h2>
<pre><code class="bash">
#!/usr/sh

# Printing(IO)
echo "Hello World"

# Variables, concatenation
name='Binny'
year=2008
echo "Hello, " $name " - welcome to " $year

#If,else conditions
if [ $year -gt 2008 ]; then
	echo "Welcome to the future - yes, we have flying cars!"

elif [ $year -lt 2008 ]; then
	echo "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!"

else
	echo "Anything wrong with your time machine? You have not gone anywhere, kiddo."
fi

# If you are using anything after this, consider using a high level language.
# For loop
for i in 1 2 3
do
	echo $i ") Hi there!"
done

#Numerical Array, foreach
rules[0]="Do no harm"
rules[1]="Obey"
rules[2]="Continue Living"

for ((i=0; i &lt; 3; i++))
do
	echo "Rule" `expr $i + 1` ":" ${rules[$i]}
done

#A While Demo
keys=(hello foo lorem)

i=0
while [ $i -lt 3 ]
do
	echo ${keys[$i]}
	i=`expr $i + 1`
done

# Function, argument, return, call
hello () {
	myname=$1  #First argument.
	echo "Hello" $myname
}
hello "Binny"

# File IO
# File reading
contents=`cat Hello.sh` #For some reason, I'm losing all the \n's in the file.
echo "Hello has `echo $contents|wc -m` chars" # Or wc -m Hello.sh

# Writing to a file
echo "Hello World from shell script" &gt; /tmp/hello.txt

# Command Executing
ls

# Regular Expressions
string="Hello World"
evil=`echo $string | grep '^Hell'`
if [ "$evil" != "" ]; then
	echo "Yup - its evil"
fi
echo "Hello World" | sed -e 's/l//g' #Will return Heo Word

# http://tldp.org/LDP/abs/html/
</code></pre>
<p>And, by the way, this will work only in Linux &#8211; or if you installed cygwin in your Windows system. Use <code>sh &lt;File_Name&gt;</code> to execute the above code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello Script for Ruby</title>
		<link>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/#comments</comments>
		<pubDate>Thu, 01 May 2008 18:05:39 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=104</guid>
		<description><![CDATA[Hello Script is a file that contains the most commonly used elements of a programming language so that it can be used as a cheatsheet when working with that language. This Hello Script for Ruby is the sixth post in this series. I have some experience with Ruby. I will not call myself an expert [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2008/05/ruby_logo.gif'><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/05/ruby_logo.gif" alt="" title="Ruby Logo" width="105" height="109" align="right" class="intro size-full wp-image-105" /></a></p>
<p class="intro"><a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a> is a <strong class="highlight">file that contains the most commonly used elements of a programming language so that it can be used as a cheatsheet</strong> when working with that language. This Hello Script for Ruby is the sixth post in this series.</p>
<p>I have some experience with Ruby. I will not call myself an expert &#8211; but I am comfortable with Ruby. <a href="http://binnyva.blogspot.com/2005/09/learning-ruby.html">I like ruby.</a> I even have written a few <a href="http://www.bin-co.com/ruby/tk/locater/">applications</a> in it.</p>
<h2>Hello Code</h2>
<pre><code class="ruby">
#!/usr/bin/ruby

print "Hello World\n"

name = "Binny"
year = 2008
print "Hello, " + name + " - welcome to " + year.to_s + "\n"

if (year &gt; 2008) then
	print "Welcome to the future - yes, we have flying cars!"
elsif (year &lt; 2008) then
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!"
else
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo."
end
print "\n\n"

# For loop like structure
0.upto(3) { |i|
	print i.to_s + ") Hi there!\n"
}
print "\n"

# Numerical array
rules = ['Do no harm', 'Obey', 'Continue Living']
i = 0
while i&lt;rules.length do
	print "Rule " + (i+1).to_s + ": " + rules[i] + "\n"
	i = i+1
end
print "\n"

# Associated arrays
associated = {
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
}
associated.each { |key,value|
	print key + " : " + value + "\n"
}
print "\n"

# Using Join and Split
csv_values = "hello,world,how,are,you\n".split(",")
print csv_values.join(":")

# Function, argument, return, call
def hello(name)
	return "Hello " + name
end
hello_string = hello("Binny")
print "Function call returned '" + hello_string + "'\n\n"

# One for the OOP fanboys - Class, members, object and stuff.
class Movie
	public
	@name = ''
	@rating = 0

	def initialize(name)
		@name = name
		self.rateMovie()
	end

	def rateMovie()
		@rating = (@name.length % 10) + 1 #IMDBs rating algorithm. True story!
	end

	def printMovieDetails()
		print "Movie : " + @name + "\n"
		print "Rating : " + '*' * @rating + "(" + @rating.to_s + ")\n\n"
	end
end
# Create the object
ncfom = Movie.new("New Country for Old Men") #It's a sequel!
ncfom.printMovieDetails()

# File IO
# File reading, easy method...
file_in = File.new('Hello.rb', 'r')
contents = file_in.read
file_in.close
print "Hello has " + contents.length.to_s + " chars\n"

# Writing to a file
file_out = File.new('/tmp/hello.txt', 'w')
file_out.print "Hello World from Ruby."
file_out.close

# Command Executing
print `ls` #Execute the command 'ls' and print its output
print "\n"

# Regular Expressions
string = "Hello World"
print "Yup - its evil\n" if(/^Hell/.match(string))
print string.gsub(/l([^l])/, '\1') #Remove an 'l' from both words. Should print 'Helo Word' - The second arg must be in single quotes

print "\n"

# Some special/only-in-ruby stuff...
# Using a library
require "fileutils"

#Using yield/code blocks...
def doXTimes(i)
	0.upto(i) {|count|
		yield count+1
	}
end
doXTimes(5) {|count|
	print count.to_s + "th Time\n"
}

</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hello Script for Tcl</title>
		<link>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/</link>
		<comments>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 17:14:29 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tcl]]></category>
		<category><![CDATA[tk]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=103</guid>
		<description><![CDATA[Tcl, or Tool Command Language, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl &#8211; its the language that introduced me [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/images/tcl.gif' alt='Tcl Logo' align="right" /></p>
<p class="intro"> <a href="http://www.tcl.tk/">Tcl, or Tool Command Language</a>, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl &#8211; its the language that introduced me to GUI programming(<a href="http://www.bin-co.com/tcl/">Tcl/Tk</a>). Now, when ever I see a GUI toolkit, I <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/">compare it to Tcl</a>.</p>
<p>I have a few years experience in Tcl &#8211; I have written a very popular <a href="http://www.bin-co.com/tcl/tutorial/">Tcl/Tk Tutorial</a> and also a <a href="http://www.bin-co.com/tcl/scripts/indexer/">few</a> <a href="http://www.bin-co.com/tcl/scripts/ri/">small</a> <a href="http://www.bin-co.com/tcl/scripts/tagview/">applications</a> in Tcl. I am not using it a lot now a days because Tk apps look really bad in Linux. This problem is not present in Windows.</p>
<h3>Hello Code</h3>
<pre><code class="tcl">
#!/usr/bin/tclsh

# Printing(IO)
puts "Hello World!\n" 

# Variables, concatenation
set name 'Binny'
set year 2008
puts [concat "Hello, "  $name  " - welcome to "  $year]

#If,else conditions
if { $year &gt; 2008 } {
	 puts "Welcome to the future - yes, we have flying cars!" 

} elseif { $year &lt; 2008 }  {
	 puts "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!" 

} else {
	 puts "Anything wrong with your time machine? You have not gone anywhere, kiddo."
}

# For loop
for { set i 0 } { $i&lt;3 } { incr i  }  {
	 puts "$i) Hi there!"
}

#Numerical Array, foreach
set rules [list "Do no harm" "Obey" "Continue Living"]

set i 0
while { $i &lt; [llength $rules] } {
	puts [concat "Rule " [expr $i+1] " : "  [lindex $rules $i]]
	incr i
}

# Associated array, while
array set associated {
	hello	"world"
	foo		"bar"
	lorem	"ipsum"
}

foreach key [array names associated] {
	 puts [concat $key " : " $associated($key)]
}

# Using Join and Split
set csv_values [split "hello,world,how,are,you\n" ","]
puts [join $csv_values ":"]

# Function, argument, return, call
proc hello { person_name } {
	return [concat "Hello, " $person_name]
}
puts [hello "Binny"]

# File IO
# File reading, easy method...
set IN [open "Hello.tcl" r]
set contents [read $IN]
close $IN
puts [concat "Hello has " [string length $contents] " chars"]

# Writing to a file
set OUT [open "/tmp/hello.txt" w]
puts $OUT "Hello World"
close $OUT

# Regular Expressions
set str "Hello World"
if { [regexp {^Hell} $str] } {
	puts "Yup, its evil"
}

puts [regsub -all {l([^l])} $str {\1}]

# Special Tcl Syntax
# Math ops
set answer [expr {3 + 2}]

# Comments
puts $answer ;# Comments in the same line as code must use ;# instead of just #

</code></pre>
<h3>Tcl/Tk Links</h3>
<ul>
<li><a href="http://www.tcl.tk/">Tcl Developer Xchange</a></li>
<li><a href="http://wiki.tcl.tk/">Tcler&#8217;s Wiki</a></li>
<li><a href="http://en.wikipedia.org/wiki/Tcl">Tcl in Wikipedia</a></li>
<li><a href="http://www.yosefk.com/blog/i-cant-believe-im-praising-tcl.html">I can’t believe I’m praising Tcl</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Hello Script</title>
		<link>http://www.bin-co.com/blog/2008/04/perl-hello-script/</link>
		<comments>http://www.bin-co.com/blog/2008/04/perl-hello-script/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 18:01:45 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/04/perl-hello-script/</guid>
		<description><![CDATA[This is the next installment of the Hello Script series &#8211; Hello Script for Perl. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. Introduction to Perl For those of who are unfamiliar [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/04/perl.gif' alt='Perl Logo' class="intro" align="right" /></p>
<p class="intro">This is the next installment of the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script series</a> &#8211; Hello Script for Perl. <strong class="highlight">&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<h2>Introduction to Perl</h2>
<p>For those of who are unfamiliar with perl, here is the Wikipedia definition&#8230;</p>
<blockquote><p>Perl is a dynamic programming language created by Larry Wall and first released in 1987. Perl borrows features from a variety of other languages including C, shell scripting (sh), AWK, sed and Lisp. Perl was widely adopted for its strengths in text processing and lack of the arbitrary limitations of many scripting languages at the time.</p></blockquote>
<p>If you are interested in learning perl, I have written a <a href="http://www.bin-co.com/perl/tutorial/">Perl Tutorial</a>. And here are some more links if you are interested</p>
<ul>
<li><a href="http://www.perl.com/">Perl.com</a></li>
<li><a href="http://www.perl.org/">The Perl Directory</a></li>
<li><a href="http://www.perlmonks.org/">Perl Monks</a></li>
</ul>
<h2>Hello Script for Perl</h2>
<pre><code class="perl">
#!/usr/bin/perl
use strict;
use warnings;

# Printing(IO)
print "Hello World!\n";

# Variables, concatenation
my $name = 'Binny';
my $year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

#If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
elsif($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

# For loop
for(my $i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

#Numerical Array, foreach
my @rules = (
	'Do no harm',
	'Obey',
	'Continue Living'
);
my $i = 1;
foreach my $rule (@rules) {
	print "Rule " . $i . " : " . $rule . "\n";
	$i++;
}

# Associated array, while
my %associated = (
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
);
while(my ($key, $value) = each(%associated)) {
	print "$key: $value\n";
}

# Using Join and Split
my @csv_values = split(',', "hello,world,how,are,you\n");
print join(":", @csv_values);

# Function, argument, return, call
sub hello {
	$name = shift; #First argument.
	return "Hello " . $name;
}
print hello("Binny");

# File IO
# File reading, easy method...
open(IN,'Hello.pl') or die("Cannot open file : $!");
my @lines = &lt;IN&gt;;
close(IN);
my $contents = join('',@lines);
print "Hello has " . length($contents) . " chars\n";
# Writing to a file
open(OUT, '&gt;/tmp/hello.txt');
print OUT "Hello World";
close(OUT);

# Command Executing
print `ls`; #Execute the command 'ls' and print its output
print "\n";

# Regular Expressions
my $string = "Hello World";
print "Yup - its evil\n" if($string =~ /^Hell/);
$string =~ s/l([^l])/$1/g; #Remove an 'l' from both words. Should print 'Helo Word'
print $string;

print "\n\n";
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/perl-hello-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python Hello Script</title>
		<link>http://www.bin-co.com/blog/2008/03/python-hello-script/</link>
		<comments>http://www.bin-co.com/blog/2008/03/python-hello-script/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 18:01:44 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/python-hello-script/</guid>
		<description><![CDATA[As promised in the last post(Hello Script for PHP), this is my Hello Script for Python. &#8216;Hello Script&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. A word of caution here &#8211; the blocks [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.bin-co.com/blog/2008/03/python-hello-script/python-logo/' rel='attachment wp-att-97' title='Python Logo'><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/03/python-logo.gif' alt='Python Logo' class="intro" align="right" /></a></p>
<p class="intro">As promised in the last post(<a href="http://www.bin-co.com/blog/2008/03/hello-script-for-php/">Hello Script for PHP</a>), this is my Hello Script for <a href="http://www.python.org/">Python</a>. <strong class="highlight">&#8216;<a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a>&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<p>A word of caution here &#8211; the blocks in Python is created using whitespace &#8211; so the indentation is important. So when you see an indentation in the below code, think of it as one tab(instead of four spaces or something).</p>
<p>I want to insert a disclaimer here &#8211; I am not that good with python. We <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/" title="	Tk Verses Gtk(And Python verses Tcl)">never really clicked</a>. I have done very limited <a href="http://www.bin-co.com/python/programs/frees/" title="Frees - PyGTK Tool to show HardDisk Space Usage">work in Python</a>. So if you notice any problems with the below script, let me know and I&#8217;ll correct it.</p>
<pre><code class="python">
#!/usr/bin/python

print "Hello World\n"

name = "Binny"
year = 2008
print "Hello, " + name + " - welcome to " + str(year) + "\n"

# If,else conditions
if (year &gt; 2008):
	print "Welcome to the future - yes, we have flying cars!\n"
elif(year &lt; 2008):
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all thats good and holy, stay away from your parents!\n"
else:
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.\n"

# For loop
for i in range(0,3):
	print str(i) + ") Hi there!"

print ""

#Numerical Array, While
rules = ['Do no harm','Obey','Continue Living']
i = 0
while(i&lt;len(rules)):
	print "Rule " + str(i+1) + " : " + rules[i]
	i = i + 1
print ""

# Associated array, foreach
associated = {
	'hello'	:	'world',
	'foo'	:	'bar',
	'lorem'	:	'ipsum'
}
for key in associated:
	print key + " : " + associated[key]
print ""

import string
csv_values = string.split("hello,world,how,are,you\n", ",")
print string.join(csv_values, ":")

# Function, argument, return, call
def hello(name):
	return "Hello " + name + "\n"

hello_string = hello("Binny")
print hello_string

# One for the OOP fanboys - Class, members, object and stuff.
class Movie:
	name = ''
	rating = 0

	def __init__(self, name):
		self.name = name
		self.rateMovie()

	def rateMovie(self):
		self.rating = (len(self.name) % 10) + 1 #IMDBs rating algorithm. True story!

	def printMovieDetails(self):
		print "Movie : ",  self.name
		print "Rating : ", '*' * self.rating , "(", self.rating ,")\n"

#Create the object
ncfom = Movie("New Country for Old Men") #It's a sequel!
ncfom.printMovieDetails()

# File IO
# File reading, easy method...
file_in  = open('Hello.py', 'r')
contents = file_in.read()
print "Current file has " + str(len(contents)) + " chars\n"
file_in.close()
# Writing to a file
file_out = open('/tmp/hello.txt', 'w')
file_out.write("Hello World")
file_out.close()

# Command Executing
import commands
import os
print "Result of 'ls' command is " + commands.getoutput('ls') #Execute the command 'ls' and print its output
print

# Regular Expressions
import re
hell_check = re.compile("^Hell")
string = "Hello World"
if hell_check.match(string): print "Yup - its evil (Compiled)"
if re.match('^Hell', string): print "Yup - its evil (Not Compiled)"
print re.sub(r'l([^l])', r'\1', string)

</code></pre>
<p>As I said last time, save this to a file and keep it around for future reference.</p>
<p>Next hello script &#8211; Perl, Ruby or Tcl/Tk? Which one do you want &#8211; leave it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/python-hello-script/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Script for PHP</title>
		<link>http://www.bin-co.com/blog/2008/03/hello-script-for-php/</link>
		<comments>http://www.bin-co.com/blog/2008/03/hello-script-for-php/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 17:44:25 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/hello-script-for-php/</guid>
		<description><![CDATA[In the last post I introduced the concept of &#8216;Hello Script&#8217; &#8211; a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">In the last post I introduced the concept of <strong>&#8216;Hello Script&#8217; &#8211; a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the languages that I am familiar with.</p>
<p>Let&#8217;s start with PHP &#8211; I already provided this as an example for the last post. Here is the entire PHP Hello Script&#8230;</p>
<pre><code class="php">
&lt;?php
// Printing(IO)
print "Hello World!\n";

// Variables, concatenation
$name = 'Binny';
$year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

//If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
else if($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

// For loop
for($i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

//Numerical Array, While
$rules = array(
	'Do no harm',
	'Obey',
	'Continue Living'
);
$i = 0;
while($i&lt;count($rules)) {
	print "Rule " . ($i+1) . " : " . $rules[$i] . "\n";
	$i++;
}

// Associated array, foreach
$associated = array(
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
);
foreach($associated as $key =&gt; $value) {
	print "$key: $value\n";
}

// Using Join and Split
$csv_values = explode(',', "hello,world,how,are,you\n");
print implode(":", $csv_values);

// Function, argument, return, call
function hello($name) {
	return "Hello " . $name;
}
$hello_string = hello("Binny");

// One for the OOP fanboys - Class, members, object and stuff.
class Movie {
	public $name = '';
	public $rating = 0;

	function __construct($name) {
		$this-&gt;name = $name;
		$this-&gt;rateMovie();
	}
	function rateMovie() {
		$this-&gt;rating = (strlen($this-&gt;name) % 10) + 1; //IMDBs rating algorithm. True story!
	}

	function printMovieDetails() {
		print "Movie : {$this-&gt;name}\n";
		print "Rating : " . str_repeat('*', $this-&gt;rating) . "({$this-&gt;rating})\n\n";
	}
}
//Create the object
$ncfom = new Movie("New Country for Old Men"); //It's a sequel!
$ncfom-&gt;printMovieDetails();

// File IO
// File reading, easy method...
$contents = file_get_contents('Hello.php');
print "Hello has " . strlen($contents) . " chars\n";
// Writing to a file
$file_handle = f<span></span>open('/tmp/hello.txt', 'w');
fputs($file_handle, "Hello World");
fclose($file_handle);

// Command Executing
print `ls`; //Execute the command 'ls' and print its output
print "\n";

// Regular Expressions
$string = "Hello World";
if(preg_match('/^Hell/', $string)) print "Yup - its evil\n";
print preg_replace('/l([^l])/', "$1", $string); //Remove an 'l' from both words. Should print 'Helo Word'

/*
 * Specialized code
 */
// Database connectivity(native)
mysql_connect('localhost', 'root', '') or die("Cannot connect to the Database server");
mysql_select_db('Data') or die('Could not find a database called "Data"');

// Executing Query
$sql_handle = mysql_query('SELECT name,url,description FROM Comment LIMIT 1') or die('Query Error: ' . mysql_error());
while($row = mysql_fetch_assoc($sql_handle)) {
	print "Name	:	$row[name]\n";
	print "URL	:	$row[url]\n";
	print "Desc	:	$row[description]\n\n";
}
/* Just a note here - if you are going to use PHP with database in a production
 * system(and you will, trust me), use a Database abstraction layer rather than
 * the above mentioned native methods.
 */

print $_REQUEST['username']; // Method to get the value of the field 'username' after a form submit. Will not work at CLI execution
</code></pre>
<p>Save this to a file and keep it around for future reference &#8211; if you are just starting out with PHP</p>
<p>Coming up next &#8211; Python Hello Script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/hello-script-for-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
